<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Rails::Generators::TestCase</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../../../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../css/github.css" type="text/css" media="screen" />
<script src="../../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>     
    <div class="banner">
        
            <span>Ruby on Rails v4.0.0</span><br />
        
        <h1>
            <span class="type">Class</span> 
            Rails::Generators::TestCase 
            
                <span class="parent">&lt; 
                    
                    <a href="../../ActiveSupport/TestCase.html">ActiveSupport::TestCase</a>
                    
                </span>
            
        </h1>
        <ul class="files">
            
            <li><a href="../../../files/railties/lib/rails/generators/test_case_rb.html">railties/lib/rails/generators/test_case.rb</a></li>
            
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
  
    <div class="description">
      
<p>This class provides a <a href="TestCase.html">TestCase</a> for testing
generators. To setup, you need just to configure the destination and set
which generator is being tested:</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">AppGeneratorTest</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">Rails</span><span class="ruby-operator">::</span><span class="ruby-constant">Generators</span><span class="ruby-operator">::</span><span class="ruby-constant">TestCase</span>
  <span class="ruby-identifier">tests</span> <span class="ruby-constant">AppGenerator</span>
  <span class="ruby-identifier">destination</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-string">&quot;../tmp&quot;</span>, <span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-keyword">__FILE__</span>))
<span class="ruby-keyword">end</span>
</pre>

<p>If you want to ensure your destination root is clean before running each
test, you can set a setup callback:</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">AppGeneratorTest</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">Rails</span><span class="ruby-operator">::</span><span class="ruby-constant">Generators</span><span class="ruby-operator">::</span><span class="ruby-constant">TestCase</span>
  <span class="ruby-identifier">tests</span> <span class="ruby-constant">AppGenerator</span>
  <span class="ruby-identifier">destination</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-string">&quot;../tmp&quot;</span>, <span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-keyword">__FILE__</span>))
  <span class="ruby-identifier">setup</span> :<span class="ruby-identifier">prepare_destination</span>
<span class="ruby-keyword">end</span>
</pre>

    </div>
  


  


  
  


  


  

  
    <!-- Includes -->
    <div class="sectiontitle">Included Modules</div>
    <ul>
      
        <li>
          
            <a href="Testing/Behaviour.html">
              Rails::Generators::Testing::Behaviour
            </a>
          
        </li>
      
        <li>
          
            <a href="Testing/SetupAndTeardown.html">
              Rails::Generators::Testing::SetupAndTeardown
            </a>
          
        </li>
      
        <li>
          
            <a href="Testing/Assertions.html">
              Rails::Generators::Testing::Assertions
            </a>
          
        </li>
      
        <li>
          
            FileUtils
          
        </li>
      
    </ul>
  



  

    

    

    


    


    <!-- Methods -->
              </div>

    </div>
  </body>
</html>    